﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QFlow.Core;

namespace QFlow.Data
{
    public partial class User : IUser
    {
        public override string ToString()
        {
            return this.Username;
        }

        #region IUser Members


        public object Userkey
        {
            get { return this.UserID; }
        }

        public bool HasPermission(object permissionKey)
        {
            int permissionId = Convert.ToInt32(permissionKey);
            return this.Role.RolePermissions.Where(rp => rp.PermissionID == permissionId).Count() > 0;
        }

        public bool HasPermission(string permissionName)
        {
            return this.Role.RolePermissions.Where(rp => rp.Permission.PermissionName == permissionName).Count() > 0;
        }

        #endregion
    }
}
